<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>倒计时案列</title>
	</head>
	<body>
		<script type="text/javascript">
			function countDown(time) {
				var nowTime = +new Date();
				var inputTime = +new Date(time);
				var times = (inputTime - nowTime) / 1000

				var d = parseInt(times / 60 / 60 / 24); //天
				d = d < 10 ? '0' + d : d;
				var h = parseInt(times / 60 / 60 % 24); //时
				h = h < 10 ? '0' + h : h;
				var m = parseInt(times / 60 % 60); //分
				m = m < 10 ? '0' + m : m;
				var s = parseInt(times % 60); //当前秒
				s = s < 10 ? '0' + s : s;
				return d + '天' + h + '时' + m + '分' + s + '秒';
			}
			console.log(countDown('2021-2-28 16:40:00'));
			var date = new Date();
			console.log(date);
		</script>
	</body>
</html>
